<?php
/*
 * form attributes
 */ 
$notExistFormAttributes = array('name' => 'accountNotExistForm','id'=>'accountNotExistForm');
$existFormAttributes = array('name' => 'accountExistForm','id'=>'accountExistForm');
 
 /*
  * postal code input
  */ 
$postalCode = array(
	'name'	=> 'postalCode',
	'value'	=>	isset($postalCode)?$postalCode:set_value('postalCode'),
	'maxlength'		=> '5'
);

/*
 * phone input
 */ 
$phone = array(
	'name'	=>	'phone',
	'value'	=>	isset($phone)?$phone:set_value('phone'),
	'maxlength'		=> '5'
);
 
/*
 * account existing inputs
 */
if(isset($accountExist)){
	if($accountExist == 'true'){
		$accountExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountExist',
			'type'  => 'radio',
			'value' => 'true',
			'checked'=>	TRUE
		);
		
		$accountNotExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountNotExist',
			'value' => 'false',
			'type'  => 'radio',
			'checked'=>	FALSE
		);
	}
	else{
		$accountExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountExist',
			'type'  => 'radio',
			'value' => 'true',
			'checked'=>	FALSE
		);
		$accountNotExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountNotExist',
			'value' => 'false',
			'type'  => 'radio',
			'checked'=>	TRUE
		);
	}
}
elseif(set_value('accountExist') != ''){
	if(set_value('accountExist') == 'true'){
		$accountExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountExist',
			'type'  => 'radio',
			'value' => 'true',
			'checked'=>	TRUE
		);
		
		$accountNotExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountNotExist',
			'value' => 'false',
			'type'  => 'radio',
			'checked'=>	FALSE
		);
	}
	else{
		$accountExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountExist',
			'type'  => 'radio',
			'value' => 'true',
			'checked'=>	FALSE
		);
		$accountNotExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountNotExist',
			'value' => 'false',
			'type'  => 'radio',
			'checked'=>	TRUE
		);
	}
}
else{
		$accountExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountExist',
			'type'  => 'radio',
			'value' => 'true',
			'checked'=>	FALSE
		);
		$accountNotExist = array(
			'name'	=> 'accountExist',
			'id'	=> 'accountNotExist',
			'value' => 'false',
			'type'  => 'radio',
			'checked'=>	TRUE
		);
}

	$accountExistHidden = array(
		'name'	=> 'accountExist',
		'id'	=> 'accountExistHidden',
		'value'	=> 'false',
		'type'	=> 'hidden'
	);
	$accountNotExistHidden = array(
		'name'	=> 'accountExist',
		'id'	=> 'accountNotExistHidden',
		'value'		=> 'true',
		'type'	=> 'hidden'
	);


$accountExistLabel = '是';
$accountNotExistLabel = '否';

/*
 * email inputs
 */

$email = array(
	'name'	=> 'loginEmail',
	'value' => isset($loginEmail)?$loginEmail:set_value('loginEmail')
);

/*
 * entity types options
 */

$entityTypeOptions = $this->config->item('entity_type', 'adsense');

/*
 * users preferred locale options
 */

$usersPreferredLocaleOptions = $this->config->item('users_preferred_locale', 'adsense');

/*
 * website locale options
 */

$websiteLocaleOptions = $this->config->item('website_locale', 'adsense');

/*
 * synServiceTypes options
 */
 $productCodeOptions = $this->config->item('product_code', 'adsense');
  
/*
 * website URL input
 */
$websiteUrl = array(
	'name'	=>	'websiteUrl',
	'value'	=>	isset($websiteUrl)?$websiteUrl:set_value('websiteUrl')
);
 
  
$developerUrl = array(
	'name'	=>	'developerUrl',
	'value'	=>	isset($developerUrl)?$developerUrl:set_value('developerUrl')
);

/*
 * email promotions preference radio
 */

if(isset($emailPromotionPreferences)){
	
	$emailPromotionPreferences = array(
		'name'	=> 'emailPromotionPreferences',
		'id'	=> 'emailPromotionPreferences',
		'type'  => 'radio',
		'value' => 'true',
		'checked' => ($emailPromotionPreferences=='true')?TRUE:FALSE
	);
	
	if($emailPromotionPreferences['checked'] == TRUE){
		$tempOppositeValue = FALSE;
	}
	else $tempOppositeValue = TRUE;
	
	$emailNotPromotionPreferences = array(
		'name'	=> 'emailPromotionPreferences',
		'id'	=> 'emailNotPromotionPreferences',
		'value' => 'false',
		'type'  => 'radio',
		'checked'=>$tempOppositeValue
	);	
}
elseif(set_value('emailPromotionPreferences') != ''){
	$emailPromotionPreferences = array(
		'name'	=> 'emailPromotionPreferences',
		'id'	=> 'emailPromotionPreferences',
		'type'  => 'radio',
		'value' => 'true',
		'checked' => (set_value('emailPromotionPreferences')=='true')?TRUE:FALSE
	);
	
	if(set_value('emailPromotionPreferences') == 'true'){
		$tempOppositeValue = FALSE;
	}
	else $tempOppositeValue = TRUE;
	
	$emailNotPromotionPreferences = array(
		'name'	=> 'emailPromotionPreferences',
		'id'	=> 'emailNotPromotionPreferences',
		'value' => 'false',
		'type'  => 'radio',
		'checked'=>$tempOppositeValue
	);	
}
else{
	$emailPromotionPreferences = array(
		'name'	=> 'emailPromotionPreferences',
		'id'	=> 'emailPromotionPreferences',
		'type'  => 'radio',
		'value' => 'true',
		'checked' => TRUE
	);

	$emailNotPromotionPreferences = array(
		'name'	=> 'emailPromotionPreferences',
		'id'	=> 'emailNotPromotionPreferences',
		'value' => 'false',
		'type'  => 'radio',
		'checked' => FALSE
	);	
}

$emailPromotionPreferencesLabel = '是';
$emailNotPromotionPreferencesLabel = '否';

$adsenseGuidelineRule1 = array(
	'name'	=>	'adsenseGuidelineRule1',
	'id'	=>	'adsenseGuidelineRule1',
	'value' =>	isset($adsenseGuidelineRule1)?$adsenseGuidelineRule1:set_value('adsenseGuidelineRule1'),
	'type'	=>	'hidden'
);
$adsenseGuidelineRule2 = array(
	'name'	=>	'adsenseGuidelineRule2',
	'id'	=>	'adsenseGuidelineRule2',
	'value' =>	isset($adsenseGuidelineRule2)?$adsenseGuidelineRule2:set_value('adsenseGuidelineRule2'),
	'type'	=>	'hidden'
);

$this->adgeek_view->header();

?>
<script language="javascript" type="text/javascript" src="/js/register_form.js"></script>
<script>
$(document).ready(function(){
});	
</script>

<div id="content">
   		<div class="mainTitle">
        	<h3><span>填寫</span> Google AdSense表單</h3>
            <!--<a href="how_1.html" title="加入會員" class="btn btn_gray">加入會員</a>-->
            <div class="nav">
           	  <div class="breadCrumb">
                	<a href="/" title="首頁">首頁</a>><a href="/account/register_form" title="填寫 Google AdSense表單">填寫 Google AdSense表單</a>
                </div>
                <ul>
                	<li class="show">
                    	<span>填寫表單</span>
                        <img src="/images/nav/mainTitle_nav_btnBg_1.png" alt="" />
                    </li>
                    <li class="hide">
                    	<span>確認資料</span>
                        <img src="/images/nav/mainTitle_nav_btnBg_2.png" alt="" />
                    </li>
                    <li class="hide">
                    	<span>註冊成功</span>
                        <img src="/images/nav/mainTitle_nav_btnBg_3.png" alt="" />
                   	</li>
                </ul>
            </div>
        </div>
        <div class="menu">
        	<ul>
            	<li class="active"><a href="register_form" title="註冊">填寫表單</a></li>
                <li>確認資訊</li>
                <li>註冊成功</li>
            </ul>
        </div>
        <div class="main">
        	<div class="line">
        		<span class="subTitle">填寫表單</span>
                <p>
                	<?php echo $this->config->item('commission_guideline', 'adsense');?>
                </p>
        	</div>
        	<?php if(isset($adseneValidationErrorCode)){ ?>
        	<div class="error_line">
        		<span class="subTitle">
        			<?php
        				$errorCodes = $this->config->item('validate_errors', 'adsense'); 
        				echo $errorCodes[$adseneValidationErrorCode];
        			?>
				</span>
        	</div>
        	<?php } ?>
            <div class="apply">
            	<ul class="first">
                	<li><span>*</span>為必填欄位</li>
                </ul>
                <div id="accountNotExistDiv">
                	<?php echo form_open('account/create_validation',$notExistFormAttributes); ?>
                <div class="tit">
                	<span class="subTitle">基本資訊</span>
                	<p>Google AdSense不會將您的個人資料外洩，請放心填寫！</p>
                </div>
                <ul> 
                    <li><span>*</span>使用者偏好語言：</li>
                    <li class="box">
                    	<?php
                    		$usersPreferredLocaleSelect = isset($usersPreferredLocale)?$usersPreferredLocale:((set_value('usersPreferredLocale'))?set_value('usersPreferredLocale'):'');
                    		echo form_dropdown('usersPreferredLocale',$usersPreferredLocaleOptions,$usersPreferredLocaleSelect); 
                    	?>
                    </li>
                    <li class="error">
                    	<?php echo form_error('usersPreferredLocale'); ?>
                    </li>
                </ul>
                <div class="tit">
                	<span class="subTitle">網站資訊</span>
                </div>
                <ul>
                    <li><span>*</span>網址：</li>
                    <li class="box">
                    	<?php echo form_input($websiteUrl); ?>
                    </li>
                    <li class="error">
                    	<?php echo form_error($websiteUrl['name']); ?>
                    </li>
                </ul>
                <ul>
                    <li><span>*</span>網站內容語言：</li>
                    <li class="box">
                    	<?php
                    		$websiteLocaleSelect = isset($websiteLocale)?$websiteLocale:((set_value('websiteLocale'))?set_value('websiteLocale'):'');
                    		echo form_dropdown('websiteLocale',$websiteLocaleOptions,$websiteLocaleSelect); 
                    	?>
                    </li>
                    <li class="error">
                    	<?php echo form_error('websiteLocale'); ?>
                    </li>
                </ul>
                <ul>
                    <li><span>*</span>欲申請廣告類型：</li>
                    <li class="box">
                    	<?php
                    		$productCodeSelect = isset($productCode)?$productCode:((set_value('productCode'))?set_value('productCode'):'');
                    		echo form_dropdown('productCode',$productCodeOptions,$productCodeSelect);
                    	?>
                    </li>
                    <li class="error">
                    	<?php echo form_error('productCode'); ?>
                    </li>
                </ul>
                <ul class="last">
                   	<?php echo form_input($adsenseGuidelineRule1); ?>
                	<?php echo form_input($adsenseGuidelineRule2); ?>
                </ul>
                	<?php echo form_close(); ?>
                </div>
            </div>
            <div class="legal">
            	<span class="subTitle">AdSense條款</span>
                <span>使用AdSense須同意下列條款 (詳細資訊)</span>
                <ul>
                    <li>
                    	<input <?php echo ($adsenseGuidelineRule1['value']=='checked' || set_value('adsenseGuidelineRule1')=='checked')?'checked':''; ?> name="adsenseGuidelineRule1" type="checkbox" value="" id="ck_1" onclick="check_rule(this)"/><label for="ck_1">不會點擊自己的AdSense廣告</label>
                    </li>
                    <li>
                        <input <?php echo ($adsenseGuidelineRule2['value']=='checked' || set_value('adsenseGuidelineRule2')=='checked')?'checked':''; ?> name="adsenseGuidelineRule2" type="checkbox" value="" id="ck_2" onclick="check_rule(this)"/>
                        <label for="ck_2">
                            已閱讀AdSense<a target="_blank" href="https://www.google.com/adsense/localized-terms?hl=zh_TW" title="條款及細則">條款及細則</a>和
                            <a target="_blank" href="https://support.google.com/adsense/bin/answer.py?hl=zh-Hant&hlrm=en&sourceid=aso&answer=48182&medium=link&subid=ww-ww-et-asui" title="計劃政策">計劃政策</a>
                        </label>
                    </li>
                    <li class="submit"><a href="javascript:;" onclick="submit_form();"  title="送出" class="btn btn_blue">送出</a></li>
                </ul>
            </div>
        </div>
    </div>
<?php
$this->adgeek_view->footer();
?>